package model.entity;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import model.entity.role.Users;

@Entity
@Table(name = "Voucher")
public class Voucher {

	private int voucherId;
	private Users user;
	private String title;
	private String description;
	private Date dateBegin;
	private Date dateEnd;
	private double discountRate;

	public Voucher() {
	}

	public Voucher(int voucherId, Users user, String title, Date dateBegin,
			Date dateEnd, double discountRate) {
		this.voucherId = voucherId;
		this.user = user;
		this.title = title;
		this.dateBegin = dateBegin;
		this.dateEnd = dateEnd;
		this.discountRate = discountRate;
	}

	public Voucher(int voucherId, Users user, String title, String description,
			Date dateBegin, Date dateEnd, double discountRate) {
		this.voucherId = voucherId;
		this.user = user;
		this.title = title;
		this.description = description;
		this.dateBegin = dateBegin;
		this.dateEnd = dateEnd;
		this.discountRate = discountRate;
	}

	@Id
	@GeneratedValue(generator = "Voucher_ID_Gen", strategy = GenerationType.IDENTITY)
	@SequenceGenerator(name = "Voucher_ID_Gen", sequenceName = "Voucher_SEQ_ID")
	@Column(name = "VoucherID", unique = true, nullable = false)
	public int getVoucherId() {
		return this.voucherId;
	}

	public void setVoucherId(int voucherId) {
		this.voucherId = voucherId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "UserID", nullable = false)
	public Users getUser() {
		return this.user;
	}

	public void setUser(Users user) {
		this.user = user;
	}

	@Column(name = "Title", nullable = false)
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "Description")
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "DateBegin", nullable = false, length = 23)
	public Date getDateBegin() {
		return this.dateBegin;
	}

	public void setDateBegin(Date dateBegin) {
		this.dateBegin = dateBegin;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "DateEnd", nullable = false, length = 23)
	public Date getDateEnd() {
		return this.dateEnd;
	}

	public void setDateEnd(Date dateEnd) {
		this.dateEnd = dateEnd;
	}

	@Column(name = "DiscountRate", nullable = false, precision = 53, scale = 0)
	public double getDiscountRate() {
		return this.discountRate;
	}

	public void setDiscountRate(double discountRate) {
		this.discountRate = discountRate;
	}

}
